<?php
namespace Zk\UserBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\Validator\Constraint\UserPassword as OldUserPassword;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;

class UserType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('email', 'email', array(
                'label' => 'form.email', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('name', null, array(
                'label' => 'form.name', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('phone', null, array(
                'label' => 'form.phone', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('sex', 'choice', array(
                'required' => false,
                'choices'   => array(1 => 'form.sex.male', 2 => 'form.sex.female'),
                'empty_value' => '',
                'label' => 'form.sex.label', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'span3',
                )
            ))
/*            ->add('balance', 'money', array(
                'disabled' => true,
                'label' => 'form.balance', 'translation_domain' => 'FOSUserBundle',
                'currency' => null,
                'attr' => array(
                    'class' => 'input-small',
                    'append_input'     => '$'
                ),
                'label_attr' => array( 'class' => 'required control-label' )
            ))*/
            ->add('timezone', 'timezone', array(
                'label' => 'form.timezone', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'span3',
                )
            ))
            //->add('enabled', null, array(
            //    'label' => 'form.enabled', 'translation_domain' => 'FOSUserBundle',
            //    'attr' => array(
            //        'class' => 'input-xlarge',
            //    )
            //))
            ->add('locked', null, array(
                'required' => false,
                'label' => 'form.locked', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('descr', 'textarea', array(
                'required' => false,
                'label' => 'form.descr', 'translation_domain' => 'FOSUserBundle',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('userRoles', 'zk_multi_select', array(
                'class' => 'ZkUserBundle:Role',
                'required' => false,
                'label' => 'form.userRoles', 'translation_domain' => 'FOSUserBundle',
                'expanded' => false,
	        'multiple' => true,
                'ZkHeight' =>  250,
                'ZkWidth'  =>  250,
                'ZkSearch' =>  'true',
                'ZkRange'  =>  'false',
	        'ZkDescr'  =>  '{\'route\':\'zk_admin_user_role_description\'}',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
            ->add('userGroups', 'zk_multi_select', array(
                'class' => 'ZkUserBundle:Group',
                'required' => false,
                'label' => 'form.userGroups', 'translation_domain' => 'FOSUserBundle',
                'expanded' => false,
	        'multiple' => true,
                'ZkHeight' =>  250,
                'ZkWidth'  =>  250,
                'ZkSearch' =>  'true',
                'ZkRange'  =>  'false',
	        'ZkDescr'  =>  '{\'route\':\'zk_admin_user_group_description\'}',
                'attr' => array(
                    'class' => 'input-xlarge',
                )
            ))
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Zk\UserBundle\Entity\User'
        ));
    }

    public function getName()
    {
        return 'zk_usertype';
    }
}
